require.config({
                baseUrl:"../",
	paths:{
		bsl:'bsl',

	}
});
require(['bsl'],function(bsl){
	document.addEventListener('deviceready', onDeviceready, false);
        function onDeviceready(){
            alert("star");
            
            //geolocation
            //初始化
            var watchID=null;
            function onSuccess(position) {
                var element = document.getElementById('cgeolocation');
                element.innerHTML = 'Latitude: '           + position.coords.latitude              + '<br />' +
                'Longitude: '          + position.coords.longitude             + '<br />' +
                'Altitude: '           + position.coords.altitude              + '<br />' +
                'Accuracy: '           + position.coords.accuracy              + '<br />' +
                'Altitude Accuracy: '  + position.coords.altitudeAccuracy      + '<br />' +
                'Heading: '            + position.coords.heading               + '<br />' +
                'Speed: '              + position.coords.speed                 + '<br />' +
                'Timestamp: '          + position.timestamp                    + '<br />';
            }
            function onError(error) {
                alert('code: '    + error.code    + '\n' +
                  'message: ' + error.message + '\n');
            }
            //调用当前设备信息接口
            bsl.geolocation.getCurrentPosition(onSuccess, onError);
            
            //设置延迟为3秒
            var options = { frequency: 3000  };
            //调用监听位置变化接口
            watchID = bsl.geolocation.watchPosition(onWSuccess, onWError, options);
            
            function onWSuccess(position) {
                var element = document.getElementById('geolocation');
                element.innerHTML = 'Latitude: '  + position.coords.latitude      + '<br />' +
                'Longitude: ' + position.coords.longitude     + '<br />' +
                '<hr />'      + element.innerHTML;
            }
            
            function onWError(error) {
                alert('code: '    + error.code    + '\n' +
                  'message: ' + error.message + '\n');
            }
            //取消监听
            function clearWatch() {
                if (watchID != null) {
                    alert('ssss');
                    bsl.geolocation.clearWatch(watchID);
                    watchID = null;
                }
            }

        }
});